﻿using Oliving.Common.MyHelper;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace EMSClient.CForm.Uc
{
    public partial class UcEquipmentName : UserControl
    {
        public UcEquipmentName()
        {
            InitializeComponent();
            panel4.Hide();
        }

        #region 事件

        public delegate void delegateHander(object sender, EventArgs e);
        public event delegateHander SetItem;

        private void label1_Click(object sender, EventArgs e)
        {
            SetItem(this, null);
        }

        private void panel2_Click(object sender, EventArgs e)
        {
            SetItem(this, null);
        }

        bool isSelect = false;
        public void SetSelColor(Color color)
        {
            if (color == Color.White)
            {
                isSelect = false;
                this.panel2.BackgroundImage = null;
            }
            else
            {
                isSelect = true;
                // this.panel2.BackgroundImage = EMSClient.Properties.Resources.列表按钮;
            }
            // this.BackColor = color;
        }

        #endregion

        #region 数据属性

        private string _MyCode { get; set; }
        public string MyCode
        {
            get { return _MyCode; }
            set { _MyCode = value; }
        }

        private string _MyIp { get; set; }
        public string MyIp
        {
            get { return _MyIp; }
            set { _MyIp = value; }
        }


        private string _MyName { get; set; }
        public string MyName
        {
            get { return _MyName; }
            set
            {

                label1.Text = value;
                _MyName = value;

                panel4.Location = new Point(label1.Location.X + label1.Width, 3);
            }
        }


        private int _MyIndexCount { get; set; }
        public int MyIndexCount
        {
            get { return _MyIndexCount; }
            set { _MyIndexCount = value; }
        }




        private int _MyAlarmManagerState { get; set; }
        public int MyAlarmManagerState
        {
            get { return _MyAlarmManagerState; }
            set { _MyAlarmManagerState = value; }
        }



        #endregion


        public void SetAlarm(bool isalarm)
        {
            if (isalarm)
            {
                panel4.Show();
                this.ucAlarmLamp1.TwinkleSpeed = 200;
                this.ucAlarmLamp1.LampColor[0] = Oliving.Common.MyHelper.ColorHelper.ToColor(0, 192, 0);
                this.ucAlarmLamp1.LampColor[1] = Oliving.Common.MyHelper.ColorHelper.ToColor(255, 77, 59);
            }
            else
            {
                panel4.Hide();
                this.ucAlarmLamp1.TwinkleSpeed = 0;
                this.ucAlarmLamp1.LampColor[0] = Oliving.Common.MyHelper.ColorHelper.ToColor(0, 192, 0);
                this.ucAlarmLamp1.LampColor[1] = Oliving.Common.MyHelper.ColorHelper.ToColor(0, 192, 0);
            }
            this.ucAlarmLamp1.Refresh();
        }
         

        public delegate void delegateHanderAlarmManager(object sender, EventArgs e);
        public event delegateHanderAlarmManager SetAlarmManager;



        private void 报警开ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.MyAlarmManagerState = 1;
            SetAlarmManager(this, null);
        }

        private void 报警关ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.MyAlarmManagerState = 0;
            SetAlarmManager(this, null);
        }

        private void ucAlarmLamp1_Click(object sender, EventArgs e)
        {
            contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);
        }

        private void ucAlarmLamp1_Load(object sender, EventArgs e)
        {

        }



        private void panel4_Click_1(object sender, EventArgs e)
        {
            contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);

        }
    }
}
